package com.atguigu.team.main;

import com.atguigu.team.domain.Architect;
import com.atguigu.team.domain.Designer;
import com.atguigu.team.domain.Employee;
import com.atguigu.team.domain.Equipment;
import com.atguigu.team.domain.NoteBook;
import com.atguigu.team.domain.PC;
import com.atguigu.team.domain.Printer;
import com.atguigu.team.domain.Programmer;
import com.atguigu.team.service.CompanyService;
import com.atguigu.team.service.Status;
import com.atguigu.team.service.TeamException;
import com.atguigu.team.service.TeamService;
import com.atguigu.team.view.TeamView;
 
public class TeamMain {
	
	public static void main(String[] args) {
		new TeamView().enterMainMenu();
	}
	
	public static void main1(String[] args) {
		CompanyService companyService = new CompanyService();
		Employee[] emps = companyService.getAllEmployees();
		for (int i = 0; i < emps.length; i++) {
			System.out.println(emps[i]);
		}
		System.out.println("-------------------------");
		Employee emp;
		try {
			emp = companyService.getEmployee(90);
			System.out.println(emp);
		} catch (TeamException e) {
			e.printStackTrace();
		}
	}
	
	public static void main0(String[] args) {
		Employee emp1 = new Employee(1, "张一", 10, 1000);
		//System.out.println(emp1);
		/*
		public Programmer(int id, 
						  String name, 
						  int age, 
						  double salary,
						  int memberId, 
						  Status status, 
						  Equipment equipment) {
		*/
		Equipment eq1 = new PC("T440", "联想14寸");
		Employee emp2 = new Programmer(2, "张二", 20, 2000, 0, Status.FREE, eq1);
		//System.out.println(emp2);
		
		/*
		public Designer(int id, 
						String name, 
						int age, 
						double salary, 
						int memberId,
						Status status, 
						Equipment equipment, 
						double bonus) { 
		 */
		Equipment eq2 = new NoteBook("MBP13", 10000);
		Employee emp3 = new Designer(3, "张三", 30, 3000, 0, Status.FREE, eq2, 30000);
		//System.out.println(emp3);
		
		/*
		public Architect(int id, 
						 String name, 
						 int age, 
						 double salary, 
						 int memberId,
						 Status status, 
						 Equipment equipment, 
						 double bonus, 
						 int stock) { 
		 */
		Equipment eq3 = new Printer("激光", "HP1020");
		Employee emp4 = new Architect(4, "张四", 40, 4000, 0, Status.VOCATION, eq3, 40000, 400000);
		//System.out.println(emp4);
		
		TeamService teamService = new TeamService();
		try {
			teamService.addMember(emp1);
		} catch (TeamException e) {
			System.out.println(e);
		}
		try {
			teamService.addMember(emp2);
		} catch (TeamException e) {
			System.out.println(e);
		}
		try {
			teamService.addMember(emp3);
		} catch (TeamException e) {
			System.out.println(e);
		}
		try {
			teamService.addMember(emp4);
		} catch (TeamException e) {
			System.out.println(e);
		}
		Programmer[] tmp = teamService.getTeam();
		for (int i = 0; i < tmp.length; i++) {
			System.out.println(tmp[i]);
		}
		System.out.println("------------------------------");
		try {
			teamService.removeMember(2);// 张二, 张三, 张四
		} catch (TeamException e) {
			System.out.println(e);
		} 
		// 删除完成后,再次遍历
		tmp = teamService.getTeam();
		for (int i = 0; i < tmp.length; i++) {
			System.out.println(tmp[i]);
		}
		System.out.println("------------------------------");
	}
}
